// 购物车
import request from '@/utils/yxRequest'
export default {
	// 获取搜索页面数据信息 https://m.you.163.com/xhr/search/init.json
	getSearchInfo(){
		return request.get(`/xhr/search/init.json`)
	},
	// 搜索时实时获取搜索提示 https://m.you.163.com/xhr/search/searchAutoComplete.json POST
	// content-type: application/x-www-form-urlencoded; charset=UTF-8
	//data数据 keywordPrefix: 手
	getSearchTipsList(keywordPrefix){
		return request({
			url:`/xhr/search/searchAutoComplete.json`,
			method: 'POST',
			headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
			data:`keywordPrefix=${keywordPrefix}`,
			// data: {keywordPrefix}  // 自动转为json格式
		})
		// return request.post(
		// 	`/xhr/search/searchAutoComplete.json`,
		// 	`keywordPrefix=${keywordPrefix}`,
		// 	{headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}}
		// )
	},
	// 点击搜索，获取搜索到的商品展示列表
	// https://m.you.163.com/xhr/search/search.json
	// https://m.you.163.com/xhr/search/search.json?__timestamp=1630401458565&needPopWindow=true&searchWordSource=1&stillSearch=false&_stat_search=userhand&itemId=0&size=40&upperPrice=-1&floorPrice=-1&matchType=0&categoryId=0&descSorted=false&sortType=0&keyword=%E6%89%8B%E6%9C%BA
	getSearchShowGoodsInfo({keyword, categoryId = 0,min=-1,max=-1,descSorted,sortType=0,matchType=0}){
		return request({
			url:`/xhr/search/search.json`,
			params:{
				needPopWindow: true,
				searchWordSource: 5,
				stillSearch: false,
				itemId: 0,
				size: 30,
				upperPrice: min,
				floorPrice: max,
				matchType,
				descSorted,
				sortType,
				__timestamp: Date.now(),
				categoryId,
				keyword,
			}
		})
	}

}
